﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Cn.Edwon.Web.Support;
using Cn.Edwon.Biz;
using Cn.Edwon.Spring;
using Cn.Cellula.Model.Content;
using System.Collections.Generic;

namespace Cn.Cellula.Website.Wuc {
    public partial class WUC_LoginBar : WucSupport {
        protected void Page_Load(object sender, EventArgs e) {
            if (base.Actor != null) {
                this.lab_UserName.Text = base.Actor.UserName;
                this.lab_RoleName.Text = base.Actor.Power.RoleName;
                this.ph_Logined.Visible = true;
                this.ph_Unlogin.Visible = false;
                this.lab_Msg.Text = LoadMsgNotice();
            } else {
                this.ph_Logined.Visible = false;
                this.ph_Unlogin.Visible = false;
            }
        }

        private String LoadMsgNotice() {
            if (!base.Ac.IsLogined) return "";
            IBiz biz = BizFactory.Get<IBiz>();
            IList<VMsgEO> list = biz.Find<VMsgEO>("from " + typeof(VMsgEO).Name + " eo where eo.Reciver = '" + this.Actor.ID + "' ");
            if (list != null && list.Count > 0) {
                return list.Count.ToString();
            }
            return "0";
        }
    }
}